package com.sa.app.utilities;

import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Point;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;

public class MapCircleOverlay extends Overlay {

	private GeoPoint point;
	private Paint paint1, paint2, paint3;
	private Integer radius; // in meters
	private String text;

	public MapCircleOverlay(GeoPoint point, Integer radius, String text) {
		this.point = point;

		paint1 = new Paint();
		paint1.setARGB(0xB0, 0, 0x66, 0x99);
		paint1.setStrokeWidth(2);
		paint1.setStrokeCap(Paint.Cap.ROUND);
		paint1.setAntiAlias(true);
		paint1.setDither(false);
		paint1.setStyle(Paint.Style.STROKE);

		paint2 = new Paint();
		paint2.setARGB(0x60, 0x33, 0xB5, 0xE5);

		paint3 = new Paint();
		paint3.setTextSize(30f);
		paint3.setARGB(0xB0, 0, 0x66, 0x99);
		this.radius = radius;

		this.text = text;
	}

	public void draw(Canvas canvas, MapView mapView, boolean shadow) {

		Point pt = mapView.getProjection().toPixels(point, null);
		float projectedRadius = mapView.getProjection().metersToEquatorPixels(
				radius);

		canvas.drawCircle(pt.x, pt.y, projectedRadius, paint2);
		canvas.drawCircle(pt.x, pt.y, projectedRadius, paint1);

		canvas.drawText(text, pt.x - 50, pt.y + 20, paint3);

	}

}